<?php #Выбор каталога для сохраниения страницы 
$elog->add($_POST);
if(isset($_POST['current']))
{
	$res='';
	$current='';
	$titles='Корень';
	/*Обратная навигация*/
	if(!empty($_POST['current']))
	{
		$current=$_POST['current'];
		$parents_ids=getIdsArr($current);
		$conn->query('select title,id from pages where id in('.implode(',',$parents_ids).') order by parents');	
		$parents_arr=array();
		while($row=$conn->fetch())
			$parents_arr[$row->id]=$row;
		$links=array('<span onclick="page_editor.changeCatalog(this,\'\')">Корень</span>');
		$parents='';
		$end=count($parents_ids)-1;
		$i=0;
		foreach($parents_ids as $id)
		{
			$parents.="#$id#";
			$title=isset($parents_arr[$id])?$parents_arr[$id]->title:$id;
			$titles.='  =&gt; '.$title;
			$links[]='<span'.($end==$i++?'':' onclick="page_editor.changeCatalog(this,\''.$parents.'\')"').'>'.$title.'</span>';
		}
		$ajax.=$load->block('crumbs',array('links'=>$links,'not_a'=>true));
	}
	$conn->query('select id,title from pages where parents=\''.mysql_escape_string($current).'\''.(!empty($_POST['page_id'])?' and id !='.mysql_escape_string($_POST['page_id']):''));
	if($conn->rowCount())
	{
		$ajax.='<ul class="to_select_list">';
			while($row=$conn->fetch())
				$ajax.='<li onclick="page_editor.changeCatalog(this,'."'$current#{$row->id}#'".')">'.$row->title.'</li>';
		$ajax.='</ul>';
	}
	else $ajax.='<div class="message">Каталог пуст</div>';
	/*Обратная навигация*/
	$ajax.=$load->block('buttons',array('attr'=>'onclick="page_editor.ok(\''.$current.'\',\''.$titles.'\');" id="catalog_select_ok"','text'=>'В этот каталог'));
	
}